package array.simple;

/**
 * 反转字符串
 * 示例 1：
 * 输入：["h","e","l","l","o"]
 * 输出：["o","l","l","e","h"]
 *
 * 示例 2：
 * 输入：["H","a","n","n","a","h"]
 * 输出：["h","a","n","n","a","H"]
 *
 * 链接：https://leetcode-cn.com/problems/reverse-string
 */
public class ReverseString_344 {

    public void reverseString(char[] s) {
        int i = 0, j = s.length - 1;
        while(i <= j) {
            char temp = s[i];
            s[i++] = s[j];
            s[j--] = temp;
        }
    }

    public static void main(String[] args) {
        ReverseString_344 rs = new ReverseString_344();
        rs.reverseString("hello".toCharArray());
    }
}
